<?php
/**
* @author Oliver Leisalu
* @package DomDateTime
*/
class DomArClassParserRecordProperty_Datetime extends DomArClassParserRecordProperty {
	
	protected $defaultValue;
	
	protected $null;
	
	protected $index;
	
	protected $dbType = 'datetime';
	
	protected function setOrm( array &$orm ) {
		$this->defaultValue =  $orm['defaultValue'];
		$this->null = !$orm['notNull'];
		$this->index =  $orm['index'];
		$this->dbType = $orm['type'] == 'date' ? 'date' : 'datetime';
	}
	
	protected function updateHandlerClassName( DomArClassParser $class ) {
		$this->handlerClassName = 'DomArProperty_DateTime';
	}

	protected function updateCreateHandlerCode( DomArClassParser $class ) {
		$this->createHandlerCode = 'new '.$this->handlerClassName.'(\''.$this->name.'\',\''.$this->dbType.'\',\''.$this->defaultValue.'\','.($this->null ? 'true' : 'false').',\''.$this->index.'\')';
	}

}
?>